<template>
	<view class="content" v-if="content">
		<i-popup v-if="popshow" bottom @close="oneClose" @confirm="propConfirm" :closeData="closeData"
			:confirmData="confirmData">
			<view class="showconel">隐私政策提示</view>
			<view class="showconel_body">
				欢迎您使用友电之星养车，我们希望通过 <text class="accord"
					@click="navTo('/pages/views/accord?agreementId=10010001', 'navigateTo')">《用户注册协议》</text> 及<text
					@click="navTo('/pages/views/accord?agreementId=10010004', 'navigateTo')"
					class="accord">《隐私政策声明》</text>帮助您了解我们如何收集、使用您的先关信息。为向您提供优质的服务，我们可能会像您申请以下相关权限：
			</view>
			<view class="showconel_body">
				1. 为了获取您附近的车店及油站，我们会申请位置权限；
			</view>
			<view class="showconel_body">
				2. 为了更换头像或上传图片，我们会申请相册或摄像头权限。
			</view>
			<view class="showconel_body" style="padding-bottom: 110rpx;">
				如您已阅读并同意正常，请点击“同意并继续”，开始使用我们的产品及服务。
			</view>
		</i-popup>
		
		<i-popup v-if='towpopshow' bottom @close="propClose" @confirm="towpropConfirm">
			<view class="showconel">温馨提示</view>
			<view class="showconel_body" style="padding-bottom: 48rpx;">
				您需要同意我们的服务协议，否则无法为您提供服务
			</view>
		</i-popup>
		
	</view>
</template>

<script lang="ts" setup>
	import {
		ref,
		defineEmits
	} from 'vue'
	import {
		setStorage,
		getStorage,
		navTo,
	} from '../../utils/common'
	import useStore from '../../stores/index'
	const closeData = {
		title: '不同意',
		show: true,
	}
	const confirmData = {
		title: '同意并继续',
		color: '#FB652E',
	}
	
	uni.hideTabBar()

	const popshow = ref(true)
	const towpopshow = ref(false)
	const content = ref(true)

	const store = useStore()
	const flag = ref(false)
	const emit = defineEmits(['success'])

	const oneClose = () => {
		towpopshow.value = true
		popshow.value = false
	}
	const propClose = () => {
		popshow.value = false
		towpopshow.value = false
		plus.runtime.disagreePrivacy();
		plus.ios.import("UIApplication").sharedApplication().performSelector("exit");
	}
	const propConfirm = () => {
		popshow.value = false
		setMap()
		store.setHomeList()
		plus.runtime.agreePrivacy();
	}
	const setMap = () => {
		// uni.getLocation({
		// 	geocode: true,
		// 	success: (res) => {
		// 		store.setLocation({
		// 			longitude: res.longitude,
		// 			latitude: res.latitude,
		// 			address: res.address || '',
		// 		})
		// 	},
		// 	fail: (err) => {
		// 		console.log(err, 'errerr');
		// 	},
		// 	complete: () => {
		// 		
		// 		flag.value = true
		// 	}
		// });
		emit('success')
		uni.showTabBar()
		setStorage('notIsAgree', false)
		content.value = false
	}

	const towpropConfirm = () => {
		towpopshow.value = false
		popshow.value = true
	}
</script>

<style lang="scss" scoped>
	.content {
		position: absolute;
		width: 100%;
		height: 100vh;
		overflow-x: hidden;
		background-color: $background-color;
		z-index: 102;
		.showconel {
			width: 100%;
			text-align: center;
			@include titlefont;
			padding: 24rpx 0;
		}

		.showconel_body {
			@include dfont;

			.accord {
				color: $dcolor;
			}
		}
	}
</style>